package com.itheima.dubbo.mysql.impl;

import cn.hutool.core.convert.Convert;
import com.alibaba.dubbo.config.annotation.Service;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.itheima.commons.pojo.domain.QuestionUserLock;
import com.itheima.dubbo.interfaces.QuestionUserLockApi;
import com.itheima.dubbo.mysql.mapper.QuestionUserLockMapper;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
@Service
public class QuestionUserLockApiImpl implements QuestionUserLockApi {
    @Autowired
    QuestionUserLockMapper questionUserLockMapper;

    @Override
    public void update(QuestionUserLock questionUserLock) {
        questionUserLockMapper.update(questionUserLock,Wrappers.lambdaQuery(QuestionUserLock.class)
                .eq(QuestionUserLock::getQuestionnaireId,questionUserLock.getQuestionnaireId())
                .eq(QuestionUserLock::getUserId,questionUserLock.getUserId()));
    }

    @Override
    public void add(QuestionUserLock questionUserLock) {
        questionUserLockMapper.insert(questionUserLock);
    }

    @Override
    public List<QuestionUserLock> findById(Long userId) {
        return questionUserLockMapper.selectList(Wrappers.lambdaQuery(QuestionUserLock.class)
                .eq(QuestionUserLock::getUserId,userId));
    }
}
